﻿@model S4Store.Models.AfterSaleReport.AfterSaleReportServiceAdvisorModel
@{
    Layout = null;
    ViewBag.Title = "SaleTimeRate";
    var container = "div" + Guid.NewGuid().ToString();
}
<div style="height:100%; overflow:auto">
@Html.Action("ReportBar", "Common", Model.BarModel)
@if (Model.StandardConfig == null)
{ 
    <text>考核目标未配置</text>
    return;
}
<div style="position:relative; width:100%">
  <div class="pagetitle">客服专员流失客户回归率对比</div>
    @{
        //公式计算
        List<dynamic> list = new List<dynamic>();
        var query = from s in Model.CSDayDatas
                    group s by s.EmployeeId into g
                    select new { g, 姓名 = g.FirstOrDefault().Employee.Name };
        foreach(var item in query)
        {
            list.Add(new
            {
                //C2
                流失回归率目标 = Model.StandardConfig.流失客户回归率目标,

                实际流失回归率 = Model.GetLSKHHGL(item.g.Key,item.g.FirstOrDefault().AddTime.Year,item.g.FirstOrDefault().AddTime.Month),

                姓名 = item.姓名,
                
                用户ID=item.g.Key
            });
        }
        

        S4Store.Models.Chart.Column ChartModel = new S4Store.Models.Chart.Column();
        ChartModel.Colors = new List<string> { S4Store.Models.Chart.Color.Green, S4Store.Models.Chart.Color.Blue };
        //ChartModel.Name = "登记客户";
        ChartModel.YAxis = "客服专员流失客户回归率对比";
        //ChartModel.Width = 500;
        //ChartModel.Height = 300;
        foreach(var item in list)
        {
            ChartModel.XAxis.Add(item.姓名);
        }

        S4Store.Models.Chart.ChartSeries series1 = new S4Store.Models.Chart.ChartSeries();
        series1.Name = "流失回归率目标";
        foreach(var item in list)
        {
            series1.Data.Add(item.流失回归率目标);
        }
        ChartModel.Serieses.Add(series1);


        S4Store.Models.Chart.ChartSeries series2 = new S4Store.Models.Chart.ChartSeries();
        series2.Name = "实际流失回归率";
        foreach(var item in list)
        {
            series2.Data.Add((item.实际流失回归率));
        }
        ChartModel.Serieses.Add(series2);
    
    
        @Html.Partial("../Chart/Column", ChartModel)
        <div style=" margin-left:70px; overflow:hidden">
        <table style="width:100%">
            <tr>
                @foreach(var item in list)
                {
                <td align="center" width="30">
                @if (item.实际流失回归率 < item.流失回归率目标)
                {
                    <a class="middlered" href="@Url.Action("BackService_CSXXX", new { sellerid = item.用户ID })" target="navtab" title="服务顾问用品过程KPI">
                        @(item.实际流失回归率 - item.流失回归率目标)%
                    </a>
                }
                else
                {
                    <a class="middlegreen" href="@Url.Action("BackService_CSXXX", new { sellerid = item.用户ID })" target="navtab" title="服务顾问用品过程KPI">
                        @(item.实际流失回归率 - item.流失回归率目标)%
                    </a>
                }

                </td>
                    }
            </tr>
        </table>
        </div>
        
        }
    
</div>
</div>